/*
 * Copyright 2013 Kenneth Syharath
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the license at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the license is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the license for specific language governing
 * permissions and limitations under the license.
 */

package randomness_measurement;

import java.util.List;

public class ShiftMeasurements {
	public static double measureOverallShift(List startList, List endList) {
		int sumShift = 0;
		
		for (Object obj: startList) {
			int oldPos = startList.indexOf(obj);
			int newPos = endList.indexOf(obj);
			sumShift += Math.abs(oldPos - newPos);
		}
		
		return sumShift/startList.size();
	}
	
	public static double calcExpectedShift(List startList) {
		int valToUse = startList.size() - 1;
		double retVal = (valToUse * (valToUse + 1)) / (3 * startList.size());
		return retVal;
	}
}
